package uk.ac.cam.tcs40.sidnet.formal;

import java.util.List;

import android.content.Context;
import android.graphics.Typeface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

public class AttendeeAdapter extends ArrayAdapter<Attendee> {

	private final Context m_Context;
	private final List<Attendee> m_Values;
	
	private Formal m_Formal;

	public AttendeeAdapter(Context context, List<Attendee> list) {
		super(context, android.R.layout.simple_list_item_1, list);
		m_Context = context;
		m_Values = list;
	}
	
	public void setFormal(Formal formal) {
		if (m_Formal ==null)
			m_Formal = formal;
	}

	@Override
	public View getView(final int position, View convertView, ViewGroup parent) {

		LayoutInflater inflater = (LayoutInflater) m_Context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);

		final View view = inflater.inflate(android.R.layout.simple_list_item_1, parent, false);

		final Attendee attendee = m_Values.get(position);
		
		TextView tv = (TextView) view.findViewById(android.R.id.text1);
		
		tv.setText(attendee.getName());
		
		if (attendee.isGuest())
			tv.setTypeface(null, Typeface.ITALIC);
		
		return view;
	}

	@Override
	public boolean isEnabled(int position) {
		return false;
	}
}
